Assignment operator
An expression is evaluated, and the result is saved in a variable:
w y = (m * x) + c;
w
w
int x, y;
x = 5;
y = 9;
cout << "The value of x is " << x << endl;
cout << "The value of y is " << y << endl;
int sum;
sum = x + y;
cout << "The sum of x and y is " << sum << endl;
The assignment will save the value of the expression in variable y.
Probably the most common assignment operator is the equals sign (=). It is called "assignment" because you are "assigning" a variable to a value. This operator takes the expression on its right-hand-side and places it into the variable on its left-hand-side. So, when you write x = 5, the operator takes the expression on the right, 5, and stores it in the variable on the left, x.
This code shows why you might want to throw away the return value of an operator. Look at the third line, x = 5. We're using the assignment operator here to place the value 5 in the variable x. Since the expression x = 5 returns a value, and we're not using it, then you could say we are ignoring the return value. However, note that a few of lines down, we are very interested in the return value of an operator. The addition operator in the expression x + y returns the sum of its left-hand-side and right-hand-side. That's how we are able to assign a value to sum. You can think of it as sum = (x + y), since that's what it's really doing.